﻿using System;
using System.Collections.Generic;
using Character;
using UnityEngine;

// Token: 0x02000202 RID: 514
public class CheckExpCanvas : MonoBehaviour
{
	// Token: 0x06000E1C RID: 3612 RVA: 0x000581F8 File Offset: 0x000563F8
	private void Start()
	{
		this.selectScene = UnityEngine.Object.FindObjectOfType<SelectScene>();
		this.isAdd = false;
		this.next = CheckExpCanvas.NEXT.CLOSE;
		this.step = CheckExpCanvas.STEP.START;
		if (GlobalData.PlayData.Progress < GamePlayData.PROGRESS.CLEAR_MAIN)
		{
			bool flag = GlobalData.PlayData.IsFlopFromBadgeNum();
			for (int i = 0; i < 4; i++)
			{
				if (GlobalData.PlayData.personality[i].IsRequireAdjustment())
				{
					CharaExpGages charaExpGages = UnityEngine.Object.Instantiate<CharaExpGages>(this.original);
					charaExpGages.gameObject.SetActive(true);
					charaExpGages.transform.SetParent(base.transform, false);
					charaExpGages.Setup((HEROINE)i, GlobalData.PlayData.personality[i]);
					this.isAdd = true;
				}
			}
			bool flag2 = GlobalData.PlayData.IsFlopFromBadgeNum();
			bool flag3 = GlobalData.PlayData.IsAllFreeFromBadgeNum();
			if (!flag && flag2)
			{
				this.next = CheckExpCanvas.NEXT.FLIP_FLOP;
			}
			else if (flag3)
			{
				this.next = CheckExpCanvas.NEXT.FINAL;
			}
		}
		else if (GlobalData.PlayData.Progress < GamePlayData.PROGRESS.ALL_FREE)
		{
			for (int j = 0; j < 3; j++)
			{
				GlobalData.PlayData.personality[j].AdjustmentExp_Free();
			}
			bool flag4 = GlobalData.PlayData.IsFlopFromBadgeNumByMariko();
			Personality personality = GlobalData.PlayData.personality[3];
			if (personality.IsRequireAdjustment())
			{
				CharaExpGages charaExpGages2 = UnityEngine.Object.Instantiate<CharaExpGages>(this.original);
				charaExpGages2.gameObject.SetActive(true);
				charaExpGages2.transform.SetParent(base.transform, false);
				charaExpGages2.Setup(HEROINE.MARIKO, personality);
				this.isAdd = true;
			}
			bool flag5 = GlobalData.PlayData.IsFlopFromBadgeNumByMariko();
			bool flag6 = GlobalData.PlayData.IsAllFreeFromBadgeNumByMariko();
			if (!flag4 && flag5)
			{
				this.next = CheckExpCanvas.NEXT.MARIKO_FLIP_FLOP;
			}
			else if (flag6)
			{
				this.next = CheckExpCanvas.NEXT.MARIKO_FINAL;
			}
		}
		else
		{
			for (int k = 0; k < 4; k++)
			{
				GlobalData.PlayData.personality[k].AdjustmentExp_Free();
			}
		}
		GlobalData.PlayData.personality[2].vaginaVirgin = false;
		int badgeNum = GlobalData.PlayData.GetBadgeNum();
		if (!GlobalData.PlayData.unlockWeaknessRecovery && badgeNum >= 6)
		{
			GlobalData.PlayData.unlockWeaknessRecovery = true;
			string item = "脱力回復機能をアンロックしました。\nH中に脱力状態になった場合\n画面右上の回復ボタンで脱力状態から回復できます。";
			this.unlockMSGs.Add(item);
		}
		if (!GlobalData.PlayData.unlockShowHitArea && badgeNum >= 9)
		{
			GlobalData.PlayData.unlockShowHitArea = true;
			string item2 = "快感エリア可視化機能をアンロックしました。\nHパッド内に快感エリアがある場合に\nその場所が表示されます。";
			this.unlockMSGs.Add(item2);
		}
		if (!GlobalData.PlayData.readAllFreeMessage && GlobalData.PlayData.Progress >= GamePlayData.PROGRESS.CLEAR_MAIN)
		{
			GlobalData.PlayData.readAllFreeMessage = true;
			this.unlockMSGs.Add("ゲームをクリアしました。\n以降はフリーモードになります。");
			this.unlockMSGs.Add("キャラの状態に関係なく\nすべての体位が選択できるようになりました。");
			this.unlockMSGs.Add("男の切り替えがアンロックされました。\n選択画面の「男」から\n主人公と広一を切り替えることが出来ます。");
			this.unlockMSGs.Add("状態変更がアンロックされました。\n選択画面の「状態」から\nキャラの状態を自由に変更出来ます。");
		}
		if (!GlobalData.PlayData.readAllFreeWithAdd && GlobalData.PlayData.Progress >= GamePlayData.PROGRESS.ALL_FREE)
		{
			GlobalData.PlayData.readAllFreeWithAdd = true;
			this.unlockMSGs.Add("真理子のストーリーをクリアしました。\n以降は真理子もフリーモードになります。");
			this.unlockMSGs.Add("真理子の状態変更がアンロックされました。\n選択画面の「状態」から\nキャラの状態を自由に変更できます。");
		}
		this.NextStep();
	}

	// Token: 0x06000E1D RID: 3613 RVA: 0x00058540 File Offset: 0x00056740
	private void Update()
	{
		if (this.step == CheckExpCanvas.STEP.EXP)
		{
			if (this.timer < 1f)
			{
				this.timer += Time.deltaTime;
				return;
			}
			if (Input.GetMouseButtonDown(0) || Input.GetKeyDown(KeyCode.Return) || Input.GetKeyDown(KeyCode.KeypadEnter))
			{
				this.NextStep();
			}
		}
	}

	// Token: 0x06000E1E RID: 3614 RVA: 0x000585A8 File Offset: 0x000567A8
	private void NextStep()
	{
		if (this.step == CheckExpCanvas.STEP.START)
		{
			if (this.isAdd)
			{
				this.step = CheckExpCanvas.STEP.EXP;
			}
			else if (this.unlockMSGs.Count > 0)
			{
				SystemSE.Play(SystemSE.SE.YES);
				this.step = CheckExpCanvas.STEP.MSG;
				this.ShowMessage();
			}
			else
			{
				this.End();
			}
		}
		else if (this.step == CheckExpCanvas.STEP.EXP)
		{
			if (this.unlockMSGs.Count > 0)
			{
				SystemSE.Play(SystemSE.SE.YES);
				this.step = CheckExpCanvas.STEP.MSG;
				this.ShowMessage();
			}
			else
			{
				this.End();
			}
		}
		else if (this.step == CheckExpCanvas.STEP.MSG)
		{
			this.unlockMSGs.RemoveAt(0);
			if (this.unlockMSGs.Count > 0)
			{
				this.ShowMessage();
			}
			else
			{
				this.End();
			}
		}
	}

	// Token: 0x06000E1F RID: 3615 RVA: 0x00058688 File Offset: 0x00056888
	private void ShowMessage()
	{
		GameControl gameControl = UnityEngine.Object.FindObjectOfType<GameControl>();
		gameControl.CreateModalMessageUI(this.unlockMSGs[0], new Action<bool>(this.ReadMessage), false);
	}

	// Token: 0x06000E20 RID: 3616 RVA: 0x000586BC File Offset: 0x000568BC
	private void ReadMessage(bool doNotAgain)
	{
		this.NextStep();
	}

	// Token: 0x06000E21 RID: 3617 RVA: 0x000586C4 File Offset: 0x000568C4
	private void End()
	{
		GameControl gameControl = null;
		if (this.next != CheckExpCanvas.NEXT.CLOSE)
		{
			gameControl = UnityEngine.Object.FindObjectOfType<GameControl>();
		}
		switch (this.next)
		{
		case CheckExpCanvas.NEXT.FLIP_FLOP:
			gameControl.ChangeScene("ADVScene", "adv/adv_01_00,ADV_Script_01_00", -1f);
			break;
		case CheckExpCanvas.NEXT.FINAL:
			gameControl.ChangeScene("ADVScene", "adv/adv_02_00,ADV_Script_02_00", -1f);
			break;
		case CheckExpCanvas.NEXT.MARIKO_FLIP_FLOP:
			gameControl.ChangeScene("ADVScene", "adv/adv_11_00,ADV_Script_11_00", -1f);
			break;
		case CheckExpCanvas.NEXT.MARIKO_FINAL:
			gameControl.ChangeScene("ADVScene", "adv/adv_12_00,ADV_Script_12_00", -1f);
			break;
		}
		base.gameObject.SetActive(false);
		this.selectScene.UpdateState();
	}

	// Token: 0x04000E8E RID: 3726
	[SerializeField]
	private CharaExpGages original;

	// Token: 0x04000E8F RID: 3727
	private float timer;

	// Token: 0x04000E90 RID: 3728
	private CheckExpCanvas.NEXT next;

	// Token: 0x04000E91 RID: 3729
	private List<string> unlockMSGs = new List<string>();

	// Token: 0x04000E92 RID: 3730
	private bool isAdd;

	// Token: 0x04000E93 RID: 3731
	private CheckExpCanvas.STEP step = CheckExpCanvas.STEP.EXP;

	// Token: 0x04000E94 RID: 3732
	private SelectScene selectScene;

	// Token: 0x02000203 RID: 515
	private enum STEP
	{
		// Token: 0x04000E96 RID: 3734
		START,
		// Token: 0x04000E97 RID: 3735
		EXP,
		// Token: 0x04000E98 RID: 3736
		MSG,
		// Token: 0x04000E99 RID: 3737
		END
	}

	// Token: 0x02000204 RID: 516
	private enum NEXT
	{
		// Token: 0x04000E9B RID: 3739
		CLOSE,
		// Token: 0x04000E9C RID: 3740
		FLIP_FLOP,
		// Token: 0x04000E9D RID: 3741
		FINAL,
		// Token: 0x04000E9E RID: 3742
		MARIKO_FLIP_FLOP,
		// Token: 0x04000E9F RID: 3743
		MARIKO_FINAL
	}
}
